<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.yaodian100.ec.member.entity.Bonus"%>
<%@page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<c-rt:set var="frontContextPath" value='<%=ServerValue.getFrontContextPath()%>'/>
<html>
<head>
<link rel="stylesheet" href="/css/jtips.css" type="text/css" id="" media="print, projection, screen" />
<script src="/js/jtip.js"></script>
<script language="javascript">
$().ready(function(){

	$("#current_location").html('&nbsp;&gt;&nbsp;我的积分&nbsp;-&nbsp;积点明细');
	$("#acc_li").attr('class','mb-tab-f');
	$("#use_li").removeAttr('class');
	$("#see_all").css({color:"black","font-weight":"bold","text-decoration":"none"});
	$("#see_all").click(function(){
		$(":tr[id*=waitUse]").show();
		$(":tr[id*=canUse]").show();
		$(":tr[id*=overUse]").show();
		$("#showNum").text('共'+$(":tr[id*=Use]").size()+'笔');
		$("#see_use").css({color:"#369","font-weight":"normal","text-decoration":"underline"});
		$("#see_wait").css({color:"#369","font-weight":"normal","text-decoration":"underline"});
		$("#see_all").css({color:"black","font-weight":"bold","text-decoration":"none"});
	});
	
	$("#see_use").click(function(){
		$(":tr[id*=overUse]").hide();
		$(":tr[id*=waitUse]").hide();
		$(":tr[id*=canUse]").show();
		$("#showNum").text('共'+$(":tr[id*=canUse]").size()+'笔');
		$("#see_all").css({color:"#369","font-weight":"normal","text-decoration":"underline"});
		$("#see_wait").css({color:"#369","font-weight":"normal","text-decoration":"underline"});
		$("#see_use").css({color:"black","font-weight":"bold","text-decoration":"none"});
	});

	$("#see_wait").click(function(){
		$(":tr[id*=overUse]").hide();
		$(":tr[id*=canUse]").hide();
		$(":tr[id*=waitUse]").show();
		$("#showNum").text('共'+$(":tr[id*=waitUse]").size()+'笔');
		$("#see_all").css({color:"#369","font-weight":"normal","text-decoration":"underline"});
		$("#see_use").css({color:"#369","font-weight":"normal","text-decoration":"underline"});
		$("#see_wait").css({color:"black","font-weight":"bold","text-decoration":"none"});
	});

	if($(":tr[id*=Use]").size()>1){
		$("#pTable").tablesorter(); 
	}

	$(":tr[id*=overUse] > td > p ").each(function(index,item){
		if((index+1) % 2 ==0){
			$(this).html($(this).text()+'<br/>(已过期)'); 
		}
	});

});
</script>
</head>
<body>
<%
@SuppressWarnings("unchecked")
List<Bonus> bonusList = (List<Bonus>)request.getAttribute("bonusList");
DateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
Bonus bonus;
%>
    <p class="LH-1of5"></p>
      <p id="showNum" class="bg-yl" align="right">共<%=bonusList.size() %>笔</p>
      <div class="a-pick-links"><a id="see_all" href="javascript:;">全部</a> | <a id="see_use" class="a-blue" href="javascript:;">可使用</a> | <a id="see_wait" class="a-blue" href="javascript:;">待生效</a></div>
      <table id="pTable" class="tablesorter {sortlist: [[0,1]]} tb-2" width="100%" border="0">
      <thead>
        <tr>
          <th width="90"><span><a href="javascript:;">获得日期</a></span></th>
          <th width="105" class="{sorter: false}">订单编号</th>
          <th><span><a href="javascript:;">获得来源</a></span></th>
          <th width="70" class="{sorter: 'digit'}"><span><a href="javascript:;">获得积分</a></span></th>
          <th width="55" class="{sorter: 'digit'}"><span><a href="javascript:;">待生效</a></span></th>
          <th width="55" class="{sorter: 'digit'}"><span><a href="javascript:;">可使用</a></span></th>
          <th width="85"><span><a href="javascript:;">生效日</a></span></th>
          <th width="85"><span><a href="javascript:;">到期日</a></span></th>
        </tr>
	  </thead>
        <%if(bonusList.size()==0){ %>
			<tr><td height="30" colspan="7">您没有任何记录。</td></tr>
        <%}else{ 
        	for(int i = 0 ; i < bonusList.size(); i++){
        		bonus = bonusList.get(i);
        		%>
        		<tr id="<%=bonus.getStartDate().getTime()>System.currentTimeMillis()?"waitUse":bonus.getExpireDate().getTime()<System.currentTimeMillis()?"overUse":"canUse" %>">
				<td><%=dateformat.format(bonus.getCreateDate()) %></td>
				<td><%if(StringUtils.isNotBlank(bonus.getOrderId())){ %>
				<a href="${frontContextPath}/member/order/page.do?page=detail&orderId=<%=bonus.getOrderId() %>" target="_blank"><%=bonus.getOrderId()%></a>
				<%}else{%>
				--
				<%}%>
				</td>
				<td><p><%=bonus.getDescription() %></p></td>
				<td class="txt-price"><%=bonus.getTrxAmount()%></td>
				<%if(bonus.getStartDate().getTime()>System.currentTimeMillis()){ %>
				<td class="txt-price"><%=bonus.getTrxAmount()%></td>
				<td>--</td>
				<%} else{%>
				<td>--</td>
				<td class="txt-price"><%=bonus.getTrxAmount().subtract(bonus.getUseBonus()).add(bonus.getRefoundBonus())%></td>
				<%} %>
				<%if( bonus.getTrxType().equals("ORDER_CANCEL") || bonus.getTrxType().equals("ORDER_RETURNED") ) {%>
				<td><a href="javascript:;?width=70&amp;" name="<%=bonus.getTrxType().equals("ORDER_CANCEL")?"订单已取消":"商品已退货" %> " id="warn<%=bonus.getId() %>" class="jTip">已取消</a></td>
				<td></td>
				<%}else{ %>
				<td><%=dateformat.format(bonus.getStartDate()) %></td>
				<td><p><%=dateformat.format(bonus.getExpireDate()) %></p></td>
				<%} %>
				</tr>
        		<%
        	}
        }%>
      </table>
      <p align="right"><a href="#"><span class="a-top"></span>Top</a></p>

      <!-- 注意事项 -->
      <div class="txt-note">
        <ul>
          <li>．您所获得的积分，将依照活动网页说明为主。</li>
		  <li>．使用明细仅显示 6 个月内的资料。</li>
        </ul>
      </div>
      <!-- 注意事项 -->
</body>
</html>